﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TjZheng.Power.DataEntity;

namespace TjZheng.CMS.Process
{
    public static class ButtonExtension
    {
        /// <summary>
        /// 将按钮权限列表转换为按钮选项列表
        /// </summary>
        /// <param name="objPowerInfoList">按钮权限列表</param>
        /// <returns></returns>
        public static IEnumerable<ButtonItem> ConvertToButtonItemList(this IEnumerable<PowerInfo> objPowerInfoList)
        {
            return objPowerInfoList.Select(c => c.ConvertToButtonItem());
        }
        /// <summary>
        /// 将按钮权限转换为按钮选项
        /// </summary>
        /// <param name="objPowerInfo">按钮权限</param>
        /// <returns></returns>
        public static ButtonItem ConvertToButtonItem(this PowerInfo objPowerInfo)
        {
            return new ButtonItem
            {
                ButtonName = objPowerInfo.PowerName,
                ButtonIcon = objPowerInfo.Icon,
                Execution = objPowerInfo.Execution,
                Position = (ButtonPosition)objPowerInfo.Position
            };
        }
    }
}
